<?php

class ctrl_firadio_php_admin_sys_procedure extends ctrl_firadio_php_admin_common {

    public function action_list() {
        // 默认的排序
        $this->table->defaorder = 'procedure.id ASC';
        // 要读取的字段
        $this->table->field = 'procedure.id,procedure.title,procedure.parentid,procedure.typename,procedure.proctext,procedure.enable';
        // 获取查询列表
        $this->tablelist = $this->table->getList();
        return($this->getdata());
    }

    public function action_add() {
        // 当表单提交时
        if ($_POST) {
            // 调用addProc执行代码添加
            $this->ret = $this->procedure->addProc($_POST);
        }
        return($this->getdata());
    }

    public function action_edit() {
        // 当有POST提交
        if ($_POST) {
            // 把POST交给模型setProc去处理
            $this->ret = $this->procedure->setProc($_GET['id'], $_POST);
        }
        // 仅查看，还没点提交
        else {
            // 提取代码信息
            $this->tables['codeinfo'] = $this->procedure->getProcById($_GET['id']);
        }
        return($this->getdata());
    }

    public function action_del() {
        // 执行删除并返回到$data['ret']
        $this->ret = $this->procedure->delProc($_GET['id']);
        return($this->getdata());
    }

    public function action_info() {
        return($this->getdata());
    }

}